<template>
    <el-descriptions title="批次入库详情">
        <el-descriptions-item label="入库单单号">{{ inventoryBatch.id }} </el-descriptions-item>
        <el-descriptions-item label="商品Id">{{ inventoryBatch.batchId }}</el-descriptions-item>
        <el-descriptions-item label="批次库存量">{{ inventoryBatch.qty }}</el-descriptions-item>
        
        <el-descriptions-item label="备注">{{ inventoryBatch.brief }}</el-descriptions-item>
       
    </el-descriptions>

    <el-table :data="tableData" style="width: 100%">
        <el-table-column fixed prop="id" label="编号" width="220" />
        <el-table-column prop="batchId" label="批次id" show-overflow-tooltip width="180" />
        <el-table-column prop="productId" label="商品id" width="100" />
        <el-table-column prop="shelfId" label="货架Id" width="120" />
        <el-table-column prop="productName" label="商品名称" show-overflow-tooltip width="180" />
        <el-table-column prop="qty" label="批次库存量" width="120" />
        <el-table-column prop="qty" label="采购数量" width="100" />
        
        <el-table-column prop="totalPrice" label="生产日期" width="170">
            <template #default="scope">
                <el-date-picker v-model="scope.row.productionDate" type="date" placeholder="选择日期"
                    style="width: 100%;"></el-date-picker>
            </template>
        </el-table-column>
        <el-table-column prop="totalPrice" label="保质期(天)" width="220">
            <template #default="scope">
                <el-input-number v-model="scope.row.shelfLife" :min="0" size="small"></el-input-number>
            </template>
        </el-table-column>
        <el-table-column prop="totalPrice" label="过期日期" width="170">
            <template #default="scope">
                <el-date-picker v-model="scope.row.expiryDate" type="date" placeholder="选择日期"
                    style="width: 100%;"></el-date-picker>
            </template>
        </el-table-column>
        <el-table-column prop="biref" label="备注" width="80" />
        <el-table-column label="入库备注" width="150">
            <template #default="scope">
                <el-input type="textarea" v-model="scope.row.Brief" size="small"></el-input>
            </template>
        </el-table-column>
    </el-table>
</template>

<script setup lang="ts">

import { inventoryBatchApi, inventoryinApi } from '@/api'
import { dayjs, ElMessage } from 'element-plus'


const route = useRoute()

const tableData = ref<any>([])


let id: any = 0
let inventoryBatch: any = {}

onMounted(() => {
    id = route.params.id
    callProductApi()
})

const callProductApi = () => {
    inventoryinApi.select({ id }).then((res: any) => {
        inventoryBatch.id = res[0].idme
        inventoryBatch.productId = res[0].productId
        inventoryBatch.brief = res[0].brief
       
    })
    inventoryBatchApi.select({ id: id }).then((res: any) => {
        res.forEach((item: any) => {
            item.realQty = item.qty
            item.ioBrief = ""
            item.productionDate = new Date(dayjs().add(-1, 'day'))
            item.shelfLife = 30
        })
        tableData.value = res
    })
}




</script>